package com.test.common.entity.perf;

import com.test.common.enums.perf.PerfScriptPlatformEnum;
import lombok.Data;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Data
@Entity
@Table(name = "t_perf_task_script", indexes = {
        @Index(name = "taskScript", columnList = "taskId", unique = true),
        @Index(name = "taskScript", columnList = "scriptId", unique = true),
})
public class PerfTaskScriptEntity {

    public PerfTaskScriptEntity() {}

    public PerfTaskScriptEntity(int taskId, int scriptId, int users, int qps) {
        this.taskId = taskId;
        this.scriptId = scriptId;
        this.users = users;
        this.qps = qps;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(columnDefinition = "INT(11) NOT NULL DEFAULT 1 COMMENT '关联的任务ID' ")
    private int taskId;

    @Column(columnDefinition = "INT(11) NOT NULL DEFAULT 1 COMMENT '关联的脚本ID' ")
    private int scriptId;

    @Column(columnDefinition = "INT(11) NOT NULL DEFAULT 1 COMMENT '预设并发' ")
    private int users;

    @Column(columnDefinition = "INT(11) NOT NULL DEFAULT 1 COMMENT '预设QPS' ")
    private int qps;

    @Column(columnDefinition = "VARCHAR(128) NOT NULL DEFAULT '' COMMENT '备注信息' ")
    private String remark = "NA";

    @Column(columnDefinition = "DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间'")
    private Date createTime = new Date();

    @Column(columnDefinition = "DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间'")
    private Date modifyTime = new Date();

    @Transient
    private String scriptName;

    @Transient
    private PerfScriptPlatformEnum platform;

    @Transient
    private List<String> resourceNames = new ArrayList<>();

    @Transient
    private List<Integer> resourceIds = new ArrayList<>();
}
